from base.base import Base
from selenium.webdriver.common.by import By
from config.config import Config
import pytest
import yaml

class Login(Base):
    #输入账号
    zhanghao_loc = (By.XPATH,'/html/body/div/div/div/form/div[1]/div/div/input')
    #输入密码
    password_loc = (By.XPATH,'/html/body/div/div/div/form/div[2]/div/div/input')
    #点击登录
    login_loc = (By.XPATH,'/html/body/div/div/div/form/div[3]/div/button')

    def user(self):
        self.send_keys(self.zhanghao_loc,'admin')

    def pwd(self):
        self.send_keys(self.password_loc,'qwe123123')

    def login(self):
        self.click(self.login_loc)

    # @pytest.mark.parametrize("username, password, msg", yaml.safe_load(open('E:\Django\DjangoProject\hubanghuzhu\Data\data.yaml', 'r', encoding='utf-8')))
    def login_success(self):
        login_url = Config().get_login_url()
        self.open_url(login_url)
        self.user()
        self.pwd()
        self.login()

